<%@ page contentType="text/html; charset=utf-8" language="java"  errorPage="" %>
<%@ page import="com.netscenery.yang.model.Container" %>
<%@ page import="com.netscenery.yang.model.Env" %>
<%@ page import="operate.OperateType"%>
<%@page import="offer.GetDataSource"%>
<%@page import="com.netscenery.yang.model.Node"%>
<%@page import="offer.SessionObj"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
Container container = new Container(new Env(),"mycontainer");
Object itemNode = request.getAttribute("itemNode");
Object opType   = request.getAttribute("opType"); //获取操作对象
if( null != itemNode){
	container = (Container)request.getAttribute("itemNode");
}
//Session ModuleStatus control
SessionObj sessionObj = (SessionObj)request.getSession().getAttribute("sessionObj");
String control_disabled = "";
if(!sessionObj.getModuleStatus().toString().equalsIgnoreCase("EDITING")){
 	control_disabled ="disabled='disabled'";
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Container</title>
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>css/items.css" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>css/subItems.css" />
	<link rel="stylesheet" type="text/css" href="<%=basePath%>/css/Tab.css" />
    <script type="text/javascript"  src="<%=basePath%>jstree-v.pre1.0/_lib/jquery.js"></script>
    <script type="text/javascript"  src="<%=basePath%>js/StringUtil.js"></script>
    <script type="text/javascript"  src="<%=basePath%>js/IfFeature.js"></script>
    <script type="text/javascript"  src="<%=basePath%>js/Tab.js"></script>
</head>

<body class="body" >
<script type="text/javascript">
   function bodyLoad(){
   <% if( (null != itemNode) 
        &&  (!opType.toString().equalsIgnoreCase(OperateType.LOAD))){ %>
   <%   		 if(opType.toString().equalsIgnoreCase(OperateType.ADD)
  				 || opType.toString().equalsIgnoreCase(OperateType.MODIFY_INCLUDE_NAME)){ %>
	   		 	 //新增节点时，重新加载树
	   		 	 var names = document.getElementById("nodeId").value.split("\\");
	   		 	 if(names.length > 2){
	   		 	 	parent.reloadTreeWithNode(document.getElementById("nodeId").value);
	   		 	 }else{
	   		 	 	parent.reloadTreeWithNode("root");
	   		 	 }
   <%   		 } %>
			 $("#opNoticeSpan").html("操作成功！");
   		 	 setTimeout(function(){$("#opNoticeSpan").html("")},3000);
   <% }%>
   }
   $(document).ready(function(){
        $("#submitButton").click(function(){
	 	     $(":input").css("border-color","");
		     if($("#_name").val().trim().length == 0){
		        $("#_name").css("border-color","red");
		        alert("name 不能为空！");
		        return;
		     }
		     //名字验证
		     if(!nameVerify($("#_name").val().trim(),$("#_name"))){
		     	 return;
		     }
		    document.getElementById("containerForm").submit(); 
		});
		 tabLaod();
		 load_Feature();
		 bodyLoad();
 	});
 	//用于保存节点中的If Feature name的列表 与IfFeature.js配合使用
 	var availableFeatures = "<%= GetDataSource.GetAvailableIfFeatureList((Node)itemNode)%>";
 	var currNodeFeatures  = "<%= GetDataSource.GetCurrNodeIfFeatureList((Node)itemNode)%>";
</script>
<!-- ***************************************** Tab Navigate Begin **************************************  -->
 <div class="navTitle" style="display:none;">
   <ul id="navTabTitle">
     <li id="mainContent_ico" onclick="showThis('mainContent')">Leaf Main Content</li>
     <li id="type_ico"><span onclick="showThis('type')">Type Edit</span><img onclick="closeTab('type')" class='TitleLiImg' width='10' height='16' src='<%=basePath %>/images/delete.png' /></li>
     <!-- 
     <li id="mimInfo_ico"><span onclick="showThis('mimInfo')">MimInfo Edit</span><img onclick="closeTab('mimInfo')" class='TitleLiImg' width='10' height='16' src='<%=basePath %>/images/delete.png' /></li>
   	 -->
   </ul>
   <div style="clear:both;"></div>
 </div>
 <!-- 
 <div id="mimInfo_tab"  style="display:none;padding:0px;margin:0px;max-height:560px;height:560px;">
 <iframe width="100%" id="MimInfo_Iframe" name="MimInfo_Iframe"  height=100% border="0" frameborder="0" src=""  ></iframe>
 </div>
  -->
 <!-- ***************************************** Tab Navigate End   **************************************  -->
 <div id="mainContent_tab" class="" style="padding:0px;margin:0px;">
 <!-- ****************************************************************************************************** -->
 <form id="containerForm" method="post" action="<%=basePath %>ContainerOpreateServlet" class="IndexFormStyle" >
   <input type="hidden"  id="nodeId" name="nodeId" value="<%=request.getAttribute("nodeId") %>"  />
   <div id="TableContent" class="tableContent" >
   	   <div class="itemTitle">
	           The Container [<%=container.getName() %>] information   
	   </div>
	   <div class="itemDiv">
	     <span class="textSpan">&nbsp;Container name:</span>
	     <input class="inputText" id="_name" name="_name" value="<%=container.getName()==null?"":container.getName()%>" />
	   </div>
	   <div class="itemDiv">
	     <% if(!container.isConfig()){ %>
          &nbsp;<input type="checkbox" id="isConfig" name = "isConfig"  value="true" />Config
         <%} else{%> 
          &nbsp;<input type="checkbox" id="isConfig" name = "isConfig" checked="checked" value="true" />Config
         <%}%> 
	   </div>
	   <div class="itemDiv">
	     <span class="textSpan">&nbsp;Presence:</span>
	     <input class="inputText" id="presence" name="presence" value="<%=container.getPresence()==null?"":container.getPresence()%>"/>
	   </div>
	   <div class="itemDiv">
	     <span class="textSpan">&nbsp;Status:</span>
	     <select style="width:305px;   height:23px;"   class="inputSelect" id="Container_status" name="Container_status">
          <% for(int i = 0 ; i < GetDataSource.getStatusList().length ; i++ ){ %>
          <%     if(container.getStatus().getStatus().equalsIgnoreCase(GetDataSource.getStatusList()[i])){ %>  
                    <option  value="<%= GetDataSource.getStatusList()[i]%>" selected="selected"><%=GetDataSource.getStatusList()[i] %></option>
          <%     }else{ %> 
                    <option  value="<%= GetDataSource.getStatusList()[i]%>" ><%=GetDataSource.getStatusList()[i] %></option>   
          <%     }
             } %>
          </select>
	   </div>
	   <!-- ***********************If Feature HTML part     Begin *************************************** -->
	   <input type="hidden" id="featureParam" name="featureParam" value="" />
	   <div id="If_Feature_Content" class="itemDiv">
	       
	   </div>
	   <!-- ***********************If Feature HTML part     End ***************************************** -->
	   <!--  
	   <div class="itemDiv">
		   <span class="textSpan">&nbsp;MimInfo:</span>
           <input type="button" id="_mimInfoEdit" value = "Edit MimInfo"  onclick="Show_MimIfoEdit()" />
	       <span class="notNullSpan">*</span>
	   </div>
	   -->
	   <div class="itemDiv">
	   		<span class="textSpan">&nbsp;Description:</span><br/>
	    	<textarea class="textArea"  id="description" name="description"><%=container.getDescription()==null?"":container.getDescription() %></textarea>
	   </div>

	   <div class="itemDiv">
	   		<span class="textSpan">&nbsp;Reference:</span><br/>
	    	<textarea class="textArea"  id="reference" name="reference"><%=container.getReference()==null?"":container.getReference() %></textarea>
	   </div>
   </div>
   <div id="submitContent" class="submitContent">
     <span id="opNoticeSpan" style="color:red;" ></span>
     <span class="textSpan">&nbsp;</span>
     <input type="button" <%=control_disabled %> id="submitButton" value="Apply"  />
   </div>
   </form>
 <!-- ****************************************************************************************************** -->
 </div>
</body>
</html>